import logging

from redis import StrictRedis


class Config():
    """配置工厂"""
    SECRET_KEY = 'fjjfdksjfjdjfdksffffffffffjfj'
    DEBUG = True
    # 配置数据库，我配置的是mysql
    SQLALCHEMY_DATABASE_URI = "mysql://root:512279csx@127.0.0.1:3306/information"
    # 是否追踪数据库、
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # app.config.setdefault('SQLALCHEMY_COMMIT_ON_TEARDOWN', False)
    # 设置数据库是否自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis数据库的ip
    REDIS_HOST = '127.0.0.1'
    # redis 的端口
    REDIS_PORT = 6379

    # 保存session配置
    SESSION_TYPE = 'redis'
    # 指定session保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 开启session签名
    SESSION_USE_SIGNER= True
    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    LOG_LEVEL = logging.DEBUG

class DevelopmentConfig(Config):
    """ 开发阶段的配置 """
    DEBUG = True

#  上线的配置
class ProductConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR

# 测试配置
class TestingConfig(Config):
    DEBUG = True


config = {
    'development_config':DevelopmentConfig,
    'product_config':ProductConfig,
    'testing_config':TestingConfig,
}